package manager.entitycreator;

import java.sql.ResultSet;
import java.sql.SQLException;

import entity.Student;

/**
 * Implements methods that describe how to extract student information from the
 * given ResultSet.
 * 
 * @author sheryl.tay.2012, mohameds.2012
 * 
 */
public class StudentCreator implements EntityCreator<Student> {

	@Override
	public Student newEntityFromResultSet(ResultSet rs) throws SQLException {
		return newStudentFromResultSet(rs);
	}

	/**
	 * Creates a new Student entity from the given result set.
	 * 
	 * @param rs
	 *            result set containing student information
	 * @return a new Student entity with information extracted from the result
	 *         set
	 * @throws SQLException
	 */
	static Student newStudentFromResultSet(ResultSet rs) throws SQLException {
		return new Student(rs.getString("student_userId"),
				rs.getString("student_password"), rs.getString("student_name"),
				rs.getString("student_school"), rs.getDouble("student_edollar"));
	}

}
